Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VarInt decoding pseudocode #4316

Merged
merged 5 commits into from
Nov 3, 2020
Merged

VarInt decoding pseudocode #4316

merged 5 commits into from
Nov 3, 2020

Conversation

MikeBishop
Copy link
Contributor

Fixes #4300, if we decide we need/want it.

@MikeBishop MikeBishop added editorial An issue that does not affect the design of the protocol; does not require consensus. -transport labels Oct 29, 2020
@MikeBishop
Copy link
Contributor Author

And yes, this handwaves over coercing the mask into the right size integer for the number of bytes you read.

Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is a fine improvement, but I will be moving all these microalgorithm pieces under a single appendix once we're done.

draft-ietf-quic-transport.md Outdated Show resolved Hide resolved
Copy link
Contributor

@janaiyengar janaiyengar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @MikeBishop -- I think this is a useful improvement.

draft-ietf-quic-transport.md Outdated Show resolved Hide resolved
Co-authored-by: Martin Thomson <mt@lowentropy.net>
@MikeBishop
Copy link
Contributor Author

I think that this is a fine improvement, but I will be moving all these microalgorithm pieces under a single appendix once we're done.

When you do that, it's probably worth copying the "Code Components" language from -recovery.

v = v & 0x3f
repeat length-1 times:
v = (v << 8) + data.next_byte()
return v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v is also in network byte-order, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'm not sure that's necessary to mention. We haven't changed it over the course of the algorithm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could it not be in network byte order? Unless next_byte does something other than read the next byte.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that we might want to say that the value still needs to converted into host byte order before it can be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this do that? I mean, the operations here are numeric, so unless << means "divide by 2^n", we're good, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah -- there's nothing here that is endian-specific.

@martinthomson martinthomson merged commit e476865 into master Nov 3, 2020
@martinthomson martinthomson deleted the transport/varint_example branch November 3, 2020 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-transport editorial An issue that does not affect the design of the protocol; does not require consensus.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conversion pseudo code would be helpful
4 participants